/*
 * @Author: xurenda <xurenda@qq.com>
 * @HomePage: https://xurenda.top
 * @Github: https://github.com/xurenda
 * @Date: 2019-10-09 22:19:54
 * @LastEditTime: 2019-12-06 23:23:00
 * @FilePath: \elegant-surf\src\router.js
 */
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'

Vue.use(Router)

export default new Router({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: [
    { // 首页
      path: '/',
      name: 'home',
      component: Home,
      children: [
        { // 导航
          path: 'navigation/:navType?',
          component: () => import('./views/Navigation.vue'),
          beforeEnter(to, from, next) {
            if (to.path === '/navigation') next('/navigation/hot')
            next()
          }
        },
        { // 应用
          path: 'application',
          component: () => import('./views/Application.vue'),
          children: [
            { path: 'tools', component: () => import('./components/application/Tools.vue'), name: 'tools' }, // 工具
            { path: 'games', component: () => import('./components/application/Games.vue') }, // 游戏
            { path: '', redirect: { name: 'tools' } }
          ]
        },
        { // 设置
          path: 'setting',
          component: () => import('./views/Setting.vue')
        },
        { // 背景
          path: 'background',
          component: () => import('./views/Background.vue'),
          children: [
            { path: 'colors', component: () => import('./components/background/Colors.vue'), name: 'colors' }, // 纯色背景
            { path: 'sketchs', component: () => import('./components/background/Sketchs.vue') }, // 效果背景
            { path: '', redirect: { name: 'colors' } }
          ]
        },
        { // 关于
          path: 'about',
          component: () => import('./views/About.vue')
        },
      ]
    },
    { // 搜索
      path: '/search',
      name: 'search',
      component: () => import('./views/Search.vue')
    },
    {
      path: '*',
      redirect: '/'
    }
  ]
})
